<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  function test(name, age) {
    this.age = age;
    this.name = name;
  }

  function test2(name, age) {
    this.age = age;
    this.name = name;
  }

  test2.prototype = test.prototype;
  test.prototype.init = function () {
    console.log(this.name);
  }
  var newObject = new test('linqinghu', 15)
  console.log(newObject);
  newObject.init();
  var newObject2 = new test2('linqighu2', 58);
  console.log(newObject2);
  newObject2.init();
</script>
</body>
</html>